package com.zy.scwwebuis.controller;

import com.zy.scwcommon.bean.AppResponse;
import com.zy.scwwebuis.service.TMemberServiceFeign;
import com.zy.scwwebuis.vo.resp.UserRespVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpSession;


/**
* @program: zyzc_springcloud
*
* @description: 登录页
*
* @author: ZYY
*
* @create: 2024-06-20 14:51
**/

@Controller
public class LoginController {
  //  @Qualifier("TMemberServiceFeignExceptionHandler")
    @Autowired
    TMemberServiceFeign tMemberServiceFeign;
    /**
     * @Description:登录页面
     * @Param:
     * @return:
     * @Author: zy
     * @Date:
    */
    @RequestMapping("/login22")
    public String login(Model model){

        return "login";
    }

    @RequestMapping("/dologin22")
    public String dologin( String loginacct,
                           String userpswd,
                          HttpSession session){
        AppResponse<UserRespVo> userresp = tMemberServiceFeign.login(loginacct, userpswd);
        UserRespVo data = userresp.getData();
        if (data==null){
            return "login";
        }
        //有数据把数据放到session中一份
        session.setAttribute("data",data);
        return "redirect:/index";
    }
}
